import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import Layout from '../Layout/index.vue'

export const musicRoutes:RouteRecordRaw = 
  {
    path: '/my',
    name: 'My',
    meta: {title: '我的音乐'}, 
    component: () => import('../views/my/My.vue'),
    children: [
      {
        path: '/my/music',
        name: 'music',
        props: route => ({ query: route.query.id}),
        component: () => import('../views/my/music.vue')
      },
      {
        path: '/my/radio',
        name: 'radio',
        component: () => import('../views/my/radio.vue')
      }
    ]
}
export const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '/',
        meta: {title: '发现音乐'},
        component: () => import('../views/Home.vue'),
      },
      musicRoutes,
      {
        path: '/about',
        meta: {title: '关于'},
        component: () => import('../views/About.vue'),
      },
    ]
  },
  {
    path: '/song',
    props: route => ({query: route.query.id}),
    component: () => import('../views/song/Song.vue'),
  },
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
